package ca.ets.osgi.reservationservice;

/**
 * Room with info such as date, hour and availability
 * @author HP_Administrator
 *
 */
public class RoomInfo {

	private String roomID;
	private String date;
	private String hourStart;
	private String hourEnd;
	private boolean isRoomTaken;
	private String reserver;
	
	public RoomInfo(){}

	
	
	/**
	 * @return the roomID
	 */
	public String getRoomID() {
		return roomID;
	}



	/**
	 * @return the hourStart
	 */
	public String getHourStart() {
		return hourStart;
	}



	/**
	 * @param hourStart the hourStart to set
	 */
	public void setHourStart(String hourStart) {
		this.hourStart = hourStart;
	}



	/**
	 * @return the hourEnd
	 */
	public String getHourEnd() {
		return hourEnd;
	}



	/**
	 * @param hourEnd the hourEnd to set
	 */
	public void setHourEnd(String hourEnd) {
		this.hourEnd = hourEnd;
	}



	/**
	 * @param roomID the roomID to set
	 */
	public void setRoomID(String roomID) {
		this.roomID = roomID;
	}



	/**
	 * @return the date
	 */
	public String getDate() {
		return date;
	}

	/**
	 * @param date the date to set
	 */
	public void setDate(String date) {
		this.date = date;
	}


	/**
	 * @return the isRoomAvailable
	 */
	public boolean isRoomTaken() {
		return isRoomTaken;
	}

	/**
	 * @param isRoomAvailable the isRoomAvailable to set
	 */
	public void setRoomTaken(boolean isRoomAvailable) {
		this.isRoomTaken = isRoomAvailable;
	}

	/**
	 * @return the reserver
	 */
	public String getReserver() {
		return reserver;
	}

	/**
	 * @param reserver the reserver to set
	 */
	public void setReserver(String reserver) {
		this.reserver = reserver;
	}
	
	/**
	 * 
	 * @param name
	 */
	public void setAvaibilityToTaken(String name, String date, String hourStart, String hourEnd){
		if(name ==null || name.trim().equals(""))
			name = "Anonymous";
		if(this.isRoomTaken()){
			this.reserver = name;
			this.isRoomTaken = true;
			this.date = date;
			this.hourStart = hourStart;
			this.hourEnd = hourEnd;
			System.out.println("[This room " + this.getRoomID() + " was taken by " + this.reserver + " on " + this.date + " From " + this.hourStart + " Until " + this.hourEnd  + "]");
			System.out.println("");
		}
		else{
			this.isRoomTaken =false;
		}

	}
	
	/**
	 * 
	 * @param name
	 */
	public void setAvaibilityToFree(String name){
		if(name ==null || name.trim().equals(""))
			name = "Anonymous";
		this.reserver = null;
		this.isRoomTaken = false;
		this.date = null;
		this.hourStart = null;
		this.hourEnd = null;
		System.out.println("This room " + this.getRoomID() + "was freed by " + name );
	}
	
	/**
	 * Indicate whether the room is freed or not with info
	 * @return
	 */
	public String indicateRoomStatus(){
		if(this.isRoomTaken()){
			return this.roomID +  " is free";
		}
		return "This room " + this.getRoomID() + "was taken by " + this.reserver + " on " + this.date + " From " + this.hourStart + " Until " + this.hourEnd ;
	}
	
	/**
	 *indicate if this room is free according to these dates 
	 * @param date
	 * @param hourStart
	 * @param hourEnd
	 * @return
	 */
	public boolean isRoomOneEqualToParameters(String date, String hourStart,
			String hourEnd){
		boolean response = false;
		if(this.isRoomTaken()){
			if(this.getDate().equalsIgnoreCase(date) && this.getHourStart().equalsIgnoreCase(hourStart) && this.getHourEnd().equalsIgnoreCase(getHourEnd())){
				response = true;
			}
		}
		
		
		
		
		return response;
	}
	
	public String toString(){
		return "This room " + this.getRoomID() + ",Reserver " + this.reserver + ",on " + this.date + ", From " + this.hourStart + " ,Until " + this.hourEnd;
	}
	
}
